<?php
	$id = $_POST['id'];
	$name = $_POST['name'];
	$link = $_POST['link'];
	$logo = $_FILES['logo']['name'];
	$aktif = $_POST['status'];

	if($logo != ''){
		$acak=rand(0000,9999);
		$lokasi_file=$_FILES['logo']['tmp_name'];
		$nama_file1=$_FILES['logo']['name'];
		$nama_file=$acak.$nama_file1;
		move_uploaded_file($lokasi_file,"../patner/"."$nama_file");
	}
	
	if(isset($_POST['submit'])){
		if($logo != ''){
			$gambar = $koneksi->query("select logo from patner where id_patner = $id");
			$g = $gambar->fetch(PDO::FETCH_ASSOC);
			unlink("../patner/$g[logo]");
			$sttmt = $koneksi->exec("update patner set nama_perusahaan='$name', link='$link', logo='$nama_file', aktif='$aktif' where id_patner=$id");
		}else{
			$sttmt = $koneksi->exec("update patner set nama_perusahaan='$name', link='$link', aktif='$aktif' where id_patner=$id");
		}
	}
	
	$url_sukses='utama.php?module=mod_partner';
	if($sttmt){
		echo "<meta http-equiv='refresh' content='0; url=$url_sukses'>";
		exit;
	}else{
		echo mysql_error();
	}
?>